import { Component } from "react";

export default class Controlled extends Component {
    state = {
        value: 'kaifamiao'
    }
    handleChange = evt => {
        this.setState({
            value: evt.target.value 
        });
    }
    handleClick = ()=>{
        this.setState({
            value: 'hello,kaifamiao.'
        });
    }
    render(){
        return (
            <div>
                <input type="text" value={this.state.value} onChange={this.handleChange} />
                <p>{this.state.value}</p>
                <button type="button" onClick={this.handleClick}>更改当前组件的状态</button>
            </div>
        )
    }
}